// 创建一个职位item
function createJobItem(jobName, jobInfo, jobTagList, jobHr, jobMoney) {
    let job = document.createElement('div');
    job.classList.add('job');

    // 职位名称
    let jobNameDom = document.createElement('div');
    jobNameDom.classList.add('job-name');
    jobNameDom.innerText = jobName;

    // 职位信息
    let jobInfoDom = document.createElement('div');
    jobInfoDom.classList.add('job-info');
    jobInfoDom.innerText = jobInfo;

    // 职位标签
    let jobTag = document.createElement('div');
    jobTag.classList.add('job-tag');
    for (let i = 0; i < jobTagList.length; i++) {
        let item = jobTagList[i];
        let tagDom = document.createElement('div');
        tagDom.classList.add('tag');
        tagDom.innerText = item;
        jobTag.appendChild(tagDom);
    }

    // 职位面试官
    let jobHrDom = document.createElement('div');
    jobHrDom.classList.add('job-hr');
    jobHrDom.innerText = jobHr;

    // 职位薪资
    let jobMoneyDom = document.createElement('div');
    jobMoneyDom.classList.add('job-money');
    jobMoneyDom.innerText = jobMoney;

    // 拼接DOM
    job.appendChild(jobNameDom);
    job.appendChild(jobInfoDom);
    job.appendChild(jobTag);
    job.appendChild(jobHrDom);
    job.appendChild(jobMoneyDom);

    return job;
}

// 创建20个动态假数据
(function () {
    let jobListDom = document.querySelector('.job-list');
    jobListDom.innerHTML = '';
    for (let i = 0; i < 20; i++) {
        let jobName = '公众号文案';
        let jobInfo = '互成一家 1-10人';
        let jobTagList = ['微信公众号', '推文编写', '推文排版'];
        let jobHr = '老于';
        let jobMoney = '5~10k';
        let jobItem = createJobItem(jobName, jobInfo, jobTagList, jobHr, jobMoney);
        jobListDom.appendChild(jobItem);
    }
})();